<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat:'yy-mm-dd',changeMonth:true});
	$(".medium").colorbox({width:"90%", height:"90%", iframe:true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>网站</th>
	<td>
		<select name="shop_id">
			<?foreach ($shop as $s):?>
			<option value="<?=$s['id']?>" <?if (isset($_GET['shop_id']) && $_GET['shop_id']==$s['id']) echo "selected='selected'"?>><?=$s['name']?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>日期</th>
	<td>
		<input type="text" class="datepicker" name="begin_date" value="<?=isset($_GET['begin_date']) ? $_GET['begin_date'] : ''?>" /> to
		<input type="text" class="datepicker" name="end_date" value="<?=isset($_GET['end_date']) ? $_GET['end_date'] : ''?>" />
	</td>
</tr>
<tr>
	<td></td>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>

<h2><a href="<?=url('DataCenter::Marketing/GAData')?>">返回数据中心首页</a></h2>
<table width="100%" class="list_table">
<tr>
	<th>日期</th>
	<th>注册量</th>
	<th>订单数量</th>
	<th>流量(IP/pv)</th>
	<th>注册转化率</th>
	<th>订单转化率</th>
	<th>CPC消耗</th>
	<th>CPC订单金额</th>
	<th>CPC ROI</th>
	<th>全站 ROI</th>
	<th>订单总金额($)</th>
	<th>订单总金额(￥)</th>
	<th>单张订单金额</th>
</tr>
<?foreach ($data as $d):?>
<tr>
	<th><a class="medium" href="<?=url('DataCenter::Marketing/ReportByDayMedium', array('shop_id'=>$_GET['shop_id'], 'begin_date'=>date('Y-m-d', $d['date']), 'end_date'=>date('Y-m-d', $d['date'])))?>"><?=date('Y-m-d',$d['date'])?></a></th>
	<td><?=$d['reg_count']?></td>
	<td><?=$d['order_count']?></td>
	<td><?=$d['ip']?> / <?=$d['pv']?></td>
	<td><?=($d['ip']) ? sprintf('%.2f', $d['reg_count']/$d['ip']*100) : '0.00'?>%</td>
	<td><?=($d['ip']) ? sprintf('%.2f', $d['order_count']/$d['ip']*100) : '0.00'?>%</td>
	<td>￥<?=number_format($d['cpc_cost'], 2)?></td>
	<td>
		<?$cpc_order_amount_rmb = $d['cpc_order_amount'] * $currency_rate;?>
		￥<?=number_format($cpc_order_amount_rmb, 2)?>
	</td>
	<td><?=($d['cpc_cost']) ? sprintf('%.2f', $cpc_order_amount_rmb/$d['cpc_cost']) : '-'?></td>
	<td>
		<?$order_amount_rmb = $d['order_amount'] * $currency_rate;?>
		<?=($d['cpc_cost']) ? sprintf('%.2f', $order_amount_rmb/$d['cpc_cost']) : '-'?>
	</td>
	<td><?=number_format($d['order_amount'], 2)?></td>
	<td><?=number_format($d['order_amount'] * $currency_rate, 2)?></td>
	<td>$<?=($d['order_amount']) ? number_format($d['order_amount']/$d['order_count'], 2) : '0.00'?></td>
</tr>
<?endforeach;?>
</table>
<?php $this->_endblock();?>